using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NTTHAO.Web.BL.Rss;
using NTTHAO.CommonWeb;

public partial class admin_webparts_Plug_ins_RssNews_RssNewsList : System.Web.UI.UserControl
{
    public static readonly int PAGE_SIZE = 50;
    public int _PageNo = 1;
    public int _PageCount = 1;
    public long _TotalItem = 0;
    public string _PageUrl = "";

    public RssPageGroup _Group = null;
    public int _MenuID = -1;
    public DataTable _List = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            int siteID = WebGlobal.GetSite().ID;
            int langID = LanguageUtility.GetLanguageID();
            _PageUrl = "?type=" + Request.QueryString["type"] + "&name=" + Request.QueryString["name"] + "&item=" + Request.QueryString["item"] + "&g=" + Request.QueryString["g"] + (Request.QueryString["m"] == null ? "" : ("&m=" + Request.QueryString["m"]));

            if (Request.QueryString["page"] != null)
            {
                try
                {
                    _PageNo = Convert.ToInt32(Request.QueryString["page"].Trim());
                }
                catch { }
            }

            _Group = new RssPageGroup(Convert.ToInt32(Request.QueryString["g"].Trim()));
            if (_Group.ID < 1)
            {
                _Group = null;
                throw new Exception("This function is not available.");
            }

            if (Request.QueryString["m"] != null)
            {
                Int32.TryParse(Request.QueryString["m"], out _MenuID);
            }

            if (_MenuID > 0)
            {
                _List = RssContentInMenu.GetPageByMenu(_MenuID, 1, true, -1, _PageNo, PAGE_SIZE, ref _TotalItem);

                this._PageCount = (int)(this._TotalItem / PAGE_SIZE + (this._TotalItem % PAGE_SIZE != 0 ? 1 : 0));
                this._PageCount = this._PageCount < 1 ? 1 : this._PageCount;
            }
        }
        catch (Exception ex)
        {
            HtmlGenericControl ctrl = new HtmlGenericControl("div");
            ctrl.InnerHtml = "<p>" + ex.Message + "</p><p>" + ex.StackTrace + "</p>";
            this.Controls.Add(ctrl);
        }
    }
}
